package com.qf.rbac2202.sys.controller;


import com.qf.rbac2202.sys.entity.SysUser;
import com.qf.rbac2202.sys.service.ISysUserService;
import com.qf.rbac2202.utils.PageVo;
import com.qf.rbac2202.utils.R;


import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * <p>
 * 系统用户 前端控制器
 * </p>
 *
 * @author lzh
 * @since 2022-10-28
 */
@RestController
@RequestMapping("/sys/user")
public class SysUserController  extends AbstractController{

    @Autowired
    ISysUserService sysUserService;

    @GetMapping("/info")
    public R  info(){
        return R.ok().put("user",getCurrentUser());
    }

    @GetMapping("/list")
    @RequiresPermissions("sys:user:list") //走到 CustomRealm中
    public R list(@RequestParam Map<String , String> params){      //如果使用map接收参数需要添加RequestParam


        PageVo<SysUser>pageVo = sysUserService.queryUserByPage(params);



        return R.ok().put("page", pageVo);

    }

}
